﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;


namespace LiveProjectManager.DDD.Domains
{
    public class Category : Base.Domain
    {
        // Constants.
        public const int NAME_MAXLENGTH = 40;

        // Primary key of a task.
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public long Id { get; set; }

        // The category name.
        [Required]
        [StringLength(NAME_MAXLENGTH)]
        public string Name { get; set; }

        // The category description.
        // This should create ntext column in Sql Server and not nvarchar.
        [Column(TypeName = "ntext")]
        [MaxLength]
        public string Description { get; set; }

        // Creation date & time.
        public DateTime CreatedOn { get; set; }

        // The resources that are referencing current category.
        public virtual ICollection<Resource> Resources { get; set; }


        override public Dictionary<string, object> toDict()
        {
            Dictionary<string, object> myDict = new Dictionary<string, object>();
            myDict.Add("Id", Id);
            myDict.Add("Name", Name);
            myDict.Add("Description", Description);
            myDict.Add("CreatedOn", CreatedOn);
            return myDict;
        }
    }
}